/*
 * training.h
 * Created on August 5, 2005; 5:32 PM
 * by vramadurai
 */
#ifndef _TRAINING_H_
#define _TRAINING_H_

#include "HsTypes.h"

hs_int16_t L_norm(hs_int32_t L_var1);

hs_int32_t
derotation_11(
                hs_int16_t * restrict ssInI,
                hs_int16_t * restrict ssInQ,
                hs_int16_t * restrict psBufI,
                hs_int16_t * restrict psBufQ,
                hs_int16_t * restrict ssCosineTable,
                hs_int16_t * restrict ssSineTable,
                hs_int32_t siRotorTableCounter,
                hs_int32_t siPhaseUpdate
            );

void
derotation_22(
                struct HS_Phy11bStr  * HS_Phy11bPtrTh,
                hs_int16_t * restrict psBufI,
                hs_int16_t * restrict psBufQ,
                hs_int16_t * restrict ssCosineTable,
                hs_int16_t * restrict ssSineTable
            );


hs_int32_t
derotation_7(
                hs_int16_t * restrict ssInI,
                hs_int16_t * restrict ssInQ,
                hs_int16_t * restrict psBufI,
                hs_int16_t * restrict psBufQ,
                hs_int16_t * restrict ssCosineTable,
                hs_int16_t * restrict ssSineTable,
                hs_int32_t siRotorTableCounter,
                hs_int32_t siPhaseUpdate
            );

void
derotation_16(
                struct HS_Phy11bStr  * HS_Phy11bPtrTh,
                hs_int16_t * restrict psBufI,
                hs_int16_t * restrict psBufQ,
                hs_int16_t * restrict ssCosineTable,
                hs_int16_t * restrict ssSineTable
            );

hs_int32_t
derotation_8(
                hs_int16_t * restrict ssInI,
                hs_int16_t * restrict ssInQ,
                hs_int16_t * restrict psBufI,
                hs_int16_t * restrict psBufQ,
                hs_int16_t * restrict ssCosineTable,
                hs_int16_t * restrict ssSineTable,
                hs_int32_t siRotorTableCounter,
                hs_int32_t siPhaseUpdate
            );

void get_oldsymbol(
                        struct HS_Phy11bStr  *HS_Phy11bPtrTh
                    );

void carrier_offset_est(
                        struct HS_Phy11bStr  * HS_Phy11bPtrTh,
                        hs_uint8_t *OneByXFormat,
                        hs_uint16_t *OneByXTbl,
                        hs_uint16_t *usAtanSlope,
                        hs_uint16_t *usAtanTbl
                     );

void junk_agc_transient(
                            struct HS_Phy11bStr  *HS_Phy11bPtrTh,
                            hs_int16_t  * restrict piEndPtrI,
                            hs_int16_t  * restrict piStartPtrI,
                            hs_int16_t  * restrict piStartPtrQ
                       );

void agc_calc(
                struct HS_Phy11bStr  *HS_Phy11bPtrTh,
                hs_int16_t * restrict asIBufOne,
                hs_int16_t * restrict asQBufOne,
                ePHYSTATES_TH *ePhyState
             );

int agc_calc2(
                struct HS_Phy11bStr  *HS_Phy11bPtrTh,
                hs_int16_t * restrict asIBufOne,
                hs_int16_t * restrict asQBufOne
             );


void get_agc_samps(
                    hs_int16_t  * restrict ssInI,
                    hs_int16_t  * restrict ssInQ
                  );

void incr_buffer_ptr(
                        struct HS_Phy11bStr  *HS_Phy11bPtrTh,
                        volatile hs_int32_t  * volatile nextFlag,
                        hs_int16_t  * restrict piEndPtrI,
                        hs_int16_t  * restrict piStartPtrI,
                        hs_int16_t  * restrict piStartPtrQ
                    );

void get_samps(
                    struct HS_Phy11bStr  *HS_Phy11bPtrTh,
                    hs_int16_t  * restrict ssInI,
                    hs_int16_t  * restrict ssInQ,
                    hs_int16_t  * restrict piEndPtrI,
                    hs_int16_t  * restrict piStartPtrI,
                    hs_int16_t  * restrict piStartPtrQ
                 );

void wlan_do_ED(
                    struct HS_Phy11bStr  *HS_Phy11bPtrTh,
                    ePHYSTATES_TH *ePhyState
               );

void wlan_do_ED_thresh(struct HS_Phy11bStr  *HS_Phy11bPtrTh);

void wlan_AGC(
                    struct HS_Phy11bStr  *HS_Phy11bPtrTh,
                    ePHYSTATES_TH *ePhyState
               );

void wlan_AGC2(
                    struct HS_Phy11bStr  *HS_Phy11bPtrTh,
                    ePHYSTATES_TH *ePhyState
               );

void wlan_do_AGC(
                    struct HS_Phy11bStr  *HS_Phy11bPtrTh,
                    ePHYSTATES_TH *ePhyState
               );

void wlan_do_agc_junk_transient(
                                struct HS_Phy11bStr  *HS_Phy11bPtrTh,
                                ePHYSTATES_TH *ePhyState
                              );

void get_carrier_symbols(
                        struct HS_Phy11bStr  *HS_Phy11bPtrTh,
                        ePHYSTATES_TH *ePhyState
                    );


void symbol_lock_th1(
                        struct HS_Phy11bStr  *HS_Phy11bPtrTh,
                        ePHYSTATES_TH *ePhyState,
                        hs_int16_t *ssSineCosineTable
                    );

void get_sin_cos_values(
                            struct HS_Phy11bStr  *HS_Phy11bPtrTh,
                            hs_int16_t * restrict ssSineCosineTable
                        );

#endif

